{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "efe8f603c3a1ea67",
   "metadata": {},
   "source": [
    "<a href=\"https://colab.research.google.com/github/jerryjliu/llama_index/blob/main/docs/examples/embeddings/ollama_embedding.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d05ee2e5015619a",
   "metadata": {},
   "source": [
    "# Ollama Embeddings"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ec795e92b745944",
   "metadata": {},
   "source": [
    "If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bd65f26028357e05",
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install llama-index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a45593c62b5a6518",
   "metadata": {},
   "outputs": [],
   "source": [
    "from llama_index.embeddings import OllamaEmbedding\n",
    "\n",
    "ollama_embedding = OllamaEmbedding(\n",
    "    model_name=\"llama2\",\n",
    "    base_url=\"http://localhost:11434\",\n",
    "    ollama_additional_kwargs={\"mirostat\": 0},\n",
    ")\n",
    "\n",
    "pass_embedding = ollama_embedding.get_text_embedding_batch(\n",
    "    [\"This is a passage!\", \"This is another passage\"], show_progress=True\n",
    ")\n",
    "print(pass_embedding)\n",
    "\n",
    "query_embedding = ollama_embedding.get_query_embedding(\"Where is blue?\")\n",
    "print(query_embedding)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
